package com.xz.knowledgeDuplication.thread.state;

/**
 * 合并线程,待此线程执行完后,再执行其他线程,其他线程阻塞(可以理解为插队)
 * @author 召
 * @date 2022-07-20 21:27:30
 */
public class Join {

    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(() -> {
            for (int i = 0; i < 1000; i++) {
                System.out.println("thread vip " + i);
            }
        });
        thread.start();
        for (int i = 0; i < 500; i++) {
            if (i == 200) {
                thread.join();
            }
            System.out.println("main " + i);
        }
    }

}
